<template>
   <view class="panel">
        <view class="panel-list-item">
            <text>收货地址</text>
            <uni-icons type="arrowright" size="15"></uni-icons>
        </view>
        <view class="panel-list-item">
            <text>联系客服</text>
            <uni-icons type="arrowright" size="15"></uni-icons>
        </view>
        <view class="panel-list-item" @click="logout">
            <text>退出登录</text>
            <uni-icons type="arrowright" size="15"></uni-icons>
        </view>
    </view>

</template>

<script>
import { mapMutations } from 'vuex';
   export default {
      data() {
         return {

         };
      },
      onLoad() {

      },
      methods: {
        ...mapMutations('m_user', ['updateUserInfo', 'updateToken','updateAddress']),
        // 退出登录
        async logout() {
            // 询问用户是否退出登录
            const [err, succ] = await uni.showModal({
                title: '提示',
                content: '确认退出登录吗？'
            }).catch(err => err)
            if (succ && succ.confirm) {
                // 用户确认了退出登录的操作
                // 需要清空 vuex 中的 userinfo、token 和 address
                this.updateUserInfo({})
                this.updateToken('')
                this.updateAddress({})
            }
        }

      }
   };
</script>

<style scoped lang='scss'>
    .panel-list-item {
        height: 45px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        font-size: 15px;
        padding: 0 10px;
    }

</style>